package models

type Response struct {
	Code int         `json:"code"`
	Msg  string      `json:"msg"`
	Data interface{} `json:"data"`
}

type Page struct {
	Count int         `json:"count"`
	Page  int         `json:"page"`
	Size  int         `json:"size"`
	Data  interface{} `json:"data"`
}

func Success(v interface{}) (res Response) {
	res = Response{
		Code: 200,
		Msg:  "操作成功",
		Data: v,
	}
	return
}

func PageSuccess(page Page) (res Response) {
	res = Response{
		Code: 200,
		Msg:  "操作成功",
		Data: Page{
			Count: page.Count,
			Page:  page.Page,
			Size:  page.Size,
			Data:  page.Data,
		},
	}
	return
}

func Error(v interface{}) (res Response) {
	res = Response{
		Code: 500,
		Msg:  "操作失败",
		Data: v,
	}
	return
}
